#pragma once

#include <cstdlib>
#include <cmath>
#include <limits>

struct SplineTuple
{
	double a, b, c, d, x;
};

class CubicSplain
{
private:
	SplineTuple *splines;
	std::size_t numberGridPoints;

	void free_mem();
	SplineTuple* getSplineForX(double x) const;
public:
	CubicSplain(); 
	~CubicSplain(); 

	void build_spline(const double *x, const double *y,  double leftGU, double rightGU, std::size_t n);
	void getSplineCoefficients(int index, double& a, double& b, double& c, double& d, double& x);

	double getF(double x) const;
	double getDiffOne(double x) const;
	double getDiffTwo(double x) const;
};